package com.ns.dcjh.utils;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.net.Uri;

import java.util.Iterator;
import java.util.List;

public class BrowserUtils {

    public static List<ResolveInfo> getBrowserList(Context context){
        PackageManager pm = context.getPackageManager();
        Intent intent = new  Intent(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_BROWSABLE);
        intent.setData(Uri.parse("http://"));
        List<ResolveInfo> activities =  pm.queryIntentActivities(intent,PackageManager.MATCH_ALL);
        String sysBrowserPackageName = "com.android.browser";
        Iterator<ResolveInfo> itr = activities.iterator();
        while (itr.hasNext()){
            ResolveInfo info = itr.next();
            if (info.activityInfo.packageName.equals(sysBrowserPackageName)){
                itr.remove();
            }
        }
        return activities;
    }

}
